<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>文档列表 - CoCo后台管理系统</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="author" content="yinqi">
<link href="__STATIC__/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="__STATIC__/admin/css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    
    <!--左侧导航-->
    {include file="../application/admin/view/common/left.html"}
    <!--End 左侧导航-->
    
    <!--头部信息-->
    {include file="../application/admin/view/common/header.html"}
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>ID</th>
                        <th>买家手机号码</th>
                        <th>订单总额</th>
                        <th>下单时间</th>
                        <th>支付时间</th>
                        <th>应付款时间</th>
                        <th>订单状态</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                      {volist name="ret" id="r1"}
                      <tr>
                        <td>{$r1.id}</td>
                        <td>{$r1.user_tell}</td>
                        <td>{$r1.sumprice}</td>
                        <td>{$r1.addtime|date="Y-m-d H:i:s",###}</td>
                        <td>{$r1.paytime|date="Y-m-d H:i:s",###}</td>
                        <td>{$r1.should_paytime|date="Y-m-d H:i:s",###}</td>
                        {if condition="$r1.statu eq 0"}
                          <td style="text-align:center">
                            <a class="btn btn-primary m-r-5"><i class="mdi mdi-plus"></i> 待付款</a>
                          </td>
                        {elseif condition="$r1.statu eq 1"/}
                          <td style="text-align:center">
                            <a class="btn btn-primary m-r-5"><i class="mdi mdi-plus"></i> 待发货</a>
                          </td>
                        {elseif condition="$r1.statu eq 2"/}
                          <td style="text-align:center">
                            <a class="btn btn-primary m-r-5"><i class="mdi mdi-plus"></i> 待收货</a>
                          </td>
                        {elseif condition="$r1.statu eq 3"/}
                          <td style="text-align:center">
                            <a class="btn btn-default m-r-5"><i class="mdi mdi-plus"></i> 被取消</a>
                          </td>
                        {elseif condition="$r1.statu eq 5"/}
                          <td style="text-align:center">
                            <a class="btn btn-default m-r-5"><i class="mdi mdi-plus"></i> 待接受</a>
                          </td>
                        {else}
                        <td style="text-align:center">
                          <a class="btn m-r-5 btn-danger" style="border:1px solid #aaa"><i class="mdi mdi-plus"></i> 完成</a>
                        </td>
                        {/if}
                        <td style="text-align:center">
                          <div class="btn-group">
                            {if condition="$r1.statu eq 1"}
                              <a class="btn btn-success m-r-5" onclick="sendFood('{$r1.id}');" href="#!"><i class="mdi mdi-check"></i>发货</a>
                            {elseif condition="$r1.statu eq 5"/}
                              <a class="btn btn-success m-r-5" onclick="acceptOrder('{$r1.id}');" href="#!"><i class="mdi mdi-check"></i>接受</a>
                            {/if}
                      </div>
                        </td>
                      </tr>
                      {/volist}
                    </tbody>
                  </table>
                </div>
                {$pageHtml}
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>
<script type="text/javascript">
layui.use('layer', function(){
  var layer = layui.layer;
});

function sendFood(id){
  $.ajax({
    url:'/admin/order/sendFood',
    type:'get',
    dataType:'json',
    data:{id:id},
    success:function(data){
      if(data.status==0){
        layer.msg(data.msg,{icon: 5,time:2000,success:function(){
          setTimeout(function(){window.location.reload();},1000);
        }});
      }else{
        layer.msg(data.msg,{icon: 6,time:2000,success:function(){
          setTimeout(function(){window.location.reload();},1000);
        }});
      }
    }
  });
}

function acceptOrder(id){
  $.ajax({
    url:'/admin/order/acceptOrder',
    type:'get',
    dataType:'json',
    data:{id:id},
    success:function(data){
      if(data.status==0){
        layer.msg(data.msg,{icon: 5,time:2000,success:function(){
          setTimeout(function(){window.location.reload();},1000);
        }});
      }else{
        layer.msg(data.msg,{icon: 6,time:2000,success:function(){
          setTimeout(function(){window.location.reload();},1000);
        }});
      }
    }
  });
}
</script>
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
});
</script>
</body>
</html>